function h_str(str,M){
    return [...str].reduce((hash,c)=>{
        hash = (31*hash + c.charCodeAt(0)) % M
    },0)
}